'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url agent/callback/pub/wbcallback 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let {
			data = {}, userInfo, util, filterResponse, originalParam
		} = event;
		let {
			customUtil,
			uniID,
			config,
			pubFun,
			vk,
			db,
			_
		} = util;
		let {
			uid,
			campaignid,
			ip,
			ua,
			clicktime,
			IMP,
			ad_id,
			creative_id,
			TSID,
			tfid,
			invite_code
		} = data;
		let res = {
			code: 0,
			msg: ""
		};
		// 业务逻辑开始-----------------------------------------------------------
		var time = new Date().getTime()
		//记录广告平台发过来的触点信息，并保存到数据库，以备后面流程调用
		let addchudian = await db.collection('jl_chudian').add({
			uid: uid,
			pt: "weibo", //平台（快手/抖音/其他等等）
			// campaignid: campaignid,
			ip: ip, //用户客户端IP
			ua: ua,
			clicktime: clicktime, //客户端发生广告点击事件的时间，以毫秒为单位时间
			callback: IMP, //一些跟广告信息相关的回调参数，内容是一个加密字符串，在调用事件回传接口的时候会用到
			aid: ad_id,
			cid: creative_id || TSID,
			tfid: tfid || 0,
			invite_code: invite_code || 0,
			time: time,
			time_str: vk.pubfn.timeFormat(new Date(), "yyyy-MM-dd hh:mm:ss")
		})



		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}